get the oid - Mailing list pgsql-novice

From Niclas Hedell
Subject get the oid
Date
Msg-id p05200f02ba926fc45c53@[192.168.0.25]
Whole thread Raw
Responses Re: get the oid  (Josh Berkus <josh@agliodbs.com>)
Re: get the oid  (Vittorio Zuccala' <vitto.z@tiscalinet.it>)
List pgsql-novice
Hi list,

I'm not only a novice to pgsql but also to sql in general (as well as new in this list)...

Here's my question: Why doesn't the following function work?

create function getoid(name) returns integer as '
declare
        ret integer;
        tablename alias for $1;
begin
        select into ret oid from tablename;
        return ret;
end;'
language 'plpgsql';

The idea is to get the oid (or whatever) from a table given by its name as a parameter to the function. It seems that the 'from' clause can't get the right table when passing a variable with the table name. I've tried everything to get this to work (castings, subqueries, etc, etc,...)

Thanx in advance! :-)

Cheers,
Nick

pgsql-novice by date:

Previous
From: Joe Conway
Date:
Subject: Re: Value of sequence last inserted
Next
From: Josh Berkus
Date:
Subject: Re: get the oid